package org.qqcui.designpattern.patterns.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * 学院实现类
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/4/29 15:34
 **/
public class Colleage extends OrganizationComponent {

    /**
     * 学院下有很多的专业
     */
    private List<OrganizationComponent> departments = new ArrayList<>();

    public Colleage(String name, String desc) {
        super(name, desc);
    }

    @Override
    protected void add(OrganizationComponent org) {
        departments.add(org);
    }

    @Override
    protected void remove(OrganizationComponent org) {
        departments.remove(org);
    }

    @Override
    protected void print() {
        System.out.println("=============" + getName() + "==========");

        for (OrganizationComponent department : departments) {
            department.print();
        }
    }
}
